//
//  UCMarker.m
//  SDK开发版本
//
//  Created by 朱国良 on 16/9/4.
//  Copyright © 2016年 北京国泰北斗科技有限公司. All rights reserved.
//

#import "UCMarker.h"
#import <GoogleMaps/GoogleMaps.h>
#import "UCMapView.h"
#import "Public.h"

@interface UCMarker()
@property(nonatomic,strong)GMSMarker *marker;
@end

@implementation UCMarker

+ (instancetype)markerWithPosition:(CLLocationCoordinate2D)position{
    return [[self alloc] initWithPosition:position];
}

- (instancetype)initWithPosition:(CLLocationCoordinate2D)position{
    self = [super init];
    if (self) {
        self.coordinate = position;
        self.marker = [GMSMarker markerWithPosition:position];
        self.marker.appearAnimation = kUCSMarkerAnimationNone;
    }
    return self;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.marker = [[GMSMarker alloc] init];
    }
    return self;
}

- (void)setAppearAnimation:(UCSMarkerAnimation)appearAnimation{
    _appearAnimation = appearAnimation;
    _marker.appearAnimation = (GMSMarkerAnimation)_appearAnimation;
}

- (void)setCoordinate:(CLLocationCoordinate2D)coordinate{
    _coordinate = coordinate;
    _marker.position = _coordinate;
}

- (CLLocationCoordinate2D)position{
    return self.marker.position;
}

- (void)setIcon:(UIImage *)icon{
    self.marker.icon = icon;
}

- (UIImage *)icon{
    return self.marker.icon;
}

- (void)setRotation:(CLLocationDegrees)rotation{
    self.marker.rotation = rotation;
}

- (CLLocationDegrees)rotation{
    return self.marker.rotation;
}

- (void)setMapView:(UCMapView *)mapView{
    super.mapView = mapView;
    self.marker.map = [mapView valueForKey:@"map"];
}

- (void)setIconView:(UIView *)iconView{

    self.marker.iconView = iconView;
}

- (UIView *)iconView{
    return self.marker.iconView;
}

- (void)setTracksViewChanges:(BOOL)tracksViewChanges{
    
    self.marker.tracksViewChanges = tracksViewChanges;
}

- (BOOL)tracksViewChanges{
    return self.marker.tracksViewChanges;
}

- (void)setTracksInfoWindowChanges:(BOOL)tracksInfoWindowChanges{
    
    self.marker.tracksInfoWindowChanges = tracksInfoWindowChanges;
}

- (BOOL)tracksInfoWindowChanges{
    return self.marker.tracksInfoWindowChanges;
}

- (void)setGroundAnchor:(CGPoint)groundAnchor{
    self.marker.groundAnchor = groundAnchor;
}

- (CGPoint)groundAnchor{
    return self.marker.groundAnchor;
}

- (void)setInfoWindowAnchor:(CGPoint)infoWindowAnchor{
    self.marker.infoWindowAnchor = infoWindowAnchor;
}

- (CGPoint)infoWindowAnchor{
    return self.marker.infoWindowAnchor;
}

- (void)setDraggable:(BOOL)draggable{
    self.marker.draggable = draggable;
}

- (BOOL)isDraggable{
    return self.marker.draggable;
}

- (void)setFlat:(BOOL)flat{
    self.marker.flat = flat;
}

- (BOOL)isFlat{
    return self.marker.flat;
}

- (void)setOpacity:(float)opacity{
    self.marker.opacity = opacity;
}
- (float)opacity{
    return self.marker.opacity;
}
- (void)setUserData:(id)userData{
    self.marker.userData = userData;
}
- (id)userData{
    return self.marker.userData;
}

- (void)setZIndex:(int)zIndex{
    super.zIndex = zIndex;
    self.marker.zIndex = zIndex;
}

- (int)zIndex{
    return self.marker.zIndex;
}

- (BOOL)isEqualToOther:(UCMarker *)marker{
    if (marker) {
        return MARKER_EQUAL_OTHER(self,marker);
    }
    return NO;
}
@end
